package org.theonept.travian.model;

import java.sql.Timestamp;

public class Entity {

	private final Long timeToRefresh = 2000l;

	private Timestamp dateDerniereMAJ = new Timestamp(0);

	/**
	 * @return the dateDerniereMAJ
	 */
	public Timestamp getDateDerniereMAJ() {
		return dateDerniereMAJ;
	}

	/**
	 * @param dateDerniereMAJ
	 *            the dateDerniereMAJ to set
	 */
	public void setDateDerniereMAJ(Timestamp dateDerniereMAJ) {
		this.dateDerniereMAJ = dateDerniereMAJ;
	}

	public boolean isUpToDate() {
		return System.currentTimeMillis() - dateDerniereMAJ.getTime() < timeToRefresh;

	}

	public void update() {
		setDateDerniereMAJ(new Timestamp(System.currentTimeMillis()));
	}
}
